<?php
/**
 * @author Biju T biju@poornam.com
 *  
 */
require_once("classes/interface/TemplateManager.php");
require_once(ROOTPATH.'/template/smarty/Smarty-2.6.23/libs/Smarty.class.php');

class SmartyTemplateManager extends Smarty implements TemplateManager {
	
	public function __construct($path){
		$conf_path = ROOTPATH.'/'.$path;
		$config = new YAMLConfigManager();
		$conf_array = $config->loadConfig($conf_path);
		//print_r("<pre>");print_r($conf_array['template']);
		if($this->smarty == null){
			$this->setConfig($conf_array);
		}
	}
	
	public function setConfig($config){
		foreach($config as $conf){
			foreach($conf as $entries){
				if($entries['name'] == 'smarty'){
					$this->template_dir = ROOTPATH.$entries['template-dir'];
					$this->compile_dir = ROOTPATH.$entries['compile-dir'];
					$this->cache_dir = ROOTPATH.$entries['cache-dir'];
				}
			}
		}
	}
}
?>